package com.ly.im.controller;

import com.ly.im.annotaion.LoginUser;
import com.ly.im.pojo.Message;
import com.ly.im.pojo.User;
import com.ly.im.service.MessageService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Author LY
 * @create 2024/2/2 16:48
 * @Description 消息
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private MessageService messageService;

    @GetMapping("/list")
    public Object list(@LoginUser User user, Long to, Integer pageNum, Integer pageSize){
        return messageService.list(user, to, pageNum, pageSize);
    }

    @PostMapping("/add")
    public Object add(@LoginUser User user, @RequestBody Message message){
        message.setFrom(user.getId());
        return messageService.addMessage(message);
    }

}
